@section('meta')
    <style>
        body{background-color: #fff;}
        .modal-content{display: unset;}
        .layui-table{width: 97%;margin: 0 auto;}
        .layui-form-select dl {min-width: 86%;}
        .new-table {margin: 20px 0;}
    </style>
@endsection
@include('Home.User.Common._meta')
<!----  职位 推荐简历  ---->
<div class="modal-content new-table" id="addNew-content2">
    <div class="layui-form">
        <div class="modal-func-btns">
            <a href="javascript:;" class="modal-save-btn" onclick="position_push('{{route('position_push',$obj->id)}}')" title="">推荐简历</a>
            <a href="javascript:location.replace(location.href);" class="modal-edit-btn" title="重置"><i class="icon icon-edit"></i></a>
        </div>
        <table class="layui-table">
            <thead>
            <tr>
                <th><input type="checkbox" lay-skin="primary" lay-filter="allChoose" disabled></th>
                <th>ID</th>
                <th>上传时间</th>
                <th>姓名</th>
                <th>性别</th>
                <th>学历</th>
                <th>工作经验</th>
                <th>简历归属</th>
                <th>求职职位</th>
                <th>求职状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($list as $item)
                <tr @if(Auth::id()!=$item->assign) style="background:#ffeded" @endif>
                    <td><input type="checkbox" value="{{$item->id}}" name="id" lay-skin="primary" @if(Auth::id()!=$item->assign) disabled @endif></td>
                    <td data-label="ID"> {{$item->id}} </td>
                    <td data-label="上传时间"> {{$item->created_at}} </td>
                    <td data-label="姓名"> {{$item->name}} </td>
                    <td data-label="性别"> {{$item->sex_name}} </td>
                    <td data-label="学历"> {{$item->education_name}} </td>
                    <td data-label="工作经验"> {{$item->experience_name}} </td>
                    <td data-label="简历归属"> <!--{{$item->user_type}}-->{{$item->assign_username}}</td>
                    <td data-label="求职职位"> {{$item->position_name}} </td>
                    <td data-label="求职状态"> {{$item->state_name}} </td>
                    <td data-label="操作" class="tac layui-row layui-col-space10">
                        <a href="javascript:;" class="edit-btn edit-client" onclick="open_button('{{route('resume_edit',$item->id)}}','查看/编辑简历')" title="查看/编辑简历"><i class="layui-icon">&#xe642;</i></a>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>

</div>
@section('footer')
    <script type="text/javascript">
        layui.use('form', function(){
            var form = layui.form;
            var $ = layui.jquery;
            form.on('checkbox(allChoose)', function(data) {
                var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
                child.each(function(index, item) {
                    item.checked = data.elem.checked;
                });
                form.render('checkbox');
            });
        });

        var ajaxStatus=1;
        function position_push(url){
            var id_array=new Array();
            $('input[name="id"]:checked').each(function(){
                id_array.push($(this).val());//向数组中添加元素
            });

            if(id_array.length){
                var _options={id_list:id_array};
                var message = '确认要推荐吗?';

                layer.confirm(message,function(index){
                    if(ajaxStatus==0){return false;}ajaxStatus=0;
                    $.ajax({
                        type: 'POST',
                        url: url,
                        data: _options,
                        dataType: 'json',
                        success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
                            // 此处可对 data 作相关处理
                            if (data.code){
                                ajaxStatus=1;
                                layer.msg('已推荐',{icon:1});
                                var index = parent.layer.getFrameIndex(window.name);
                                window.parent.location.reload();
                                parent.layer.close(index);
                            }else{
                                layer.msg(data.msg,{icon:2,time:1000});
                            }
                            ajaxStatus=1;
                        },
                        error: function(data) {
                            var json=JSON.parse(data.responseText);
                            var str = '';
                            $.each(json.errors,function(key,val){
                                str += val + '\r\n';  //到这里终于拿到返回name字段的错误信息了
                            });
                            layer.msg(str,{icon:2,time:1000});
                            ajaxStatus=1;
                        },
                    });
                });
            }else{
                layer.msg('未选择数据!',{icon: 5,time:1000});
            }
        }

    </script>
@endsection
@include('Home.User.Common._footer')
@include('Home.User.Common._form')